package com.ygqh.baby.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;

public class BmdismModel implements Serializable, Comparable<BmdismModel> {

    /**
     */
    private static final long serialVersionUID = 8300933347792637121L;

    private Long id;

    private String title;

    private int buyCount;

    private BigDecimal disCount;

    private Date startTime;

    private Date endTime;

    private String productIds;

    private List<String> productIdList;

    public List<String> getProductIdList() {
        return productIdList;
    }

    public void setProductIdList(List<String> productIdList) {
        this.productIdList = productIdList;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getBuyCount() {
        return buyCount;
    }

    public Long getBuyCountL() {
        return (long) buyCount;
    }

    public void setBuyCount(int buyCount) {
        this.buyCount = buyCount;
    }

    public BigDecimal getDisCount() {
        return disCount;
    }

    public void setDisCount(BigDecimal disCount) {
        this.disCount = disCount;
    }

    // public Long getStartTime() {
    // return startTime;
    // }
    //
    // public void setStartTime(Long startTime) {
    // this.startTime = startTime;
    // }
    //
    // public Long getEndTime() {
    // return endTime;
    // }
    //
    // public void setEndTime(Long endTime) {
    // this.endTime = endTime;
    // }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getProductIds() {
        return productIds;
    }

    public void setProductIds(String productIds) {
        this.productIds = productIds;
    }

    public Boolean isValid() {

        long millis = System.currentTimeMillis();
        if (millis - startTime.getTime() >= 0 && millis - endTime.getTime() < 0) {
            return true;
        }
        return false;

    }

    public BmdismModel() {
        super();
    }

    public BmdismModel(Long id, String title, int buyCount, BigDecimal disCount, Date startTime, Date endTime, String productIds) {
        super();
        this.id = id;
        this.title = title;
        this.buyCount = buyCount;
        this.disCount = disCount;
        this.startTime = startTime;
        this.endTime = endTime;
        this.productIds = productIds;
    }

    @Override
    public String toString() {
        return "BmdismModel [id=" + id + ", buyCount=" + buyCount + ", disCount=" + disCount + ", startTime=" + startTime + ", endTime=" + endTime
                + ", productIds=" + productIds + "]";
    }

    @Override
    public int compareTo(BmdismModel o) {

        return this.buyCount - o.getBuyCount();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        BmdismModel that = (BmdismModel) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(productIds, that.productIds);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, productIds);
    }
}
